package ren.kane.asdppp;

import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author renrk(1275) on 2019-04-09 7:27 PM
 **/
@Repository
public class PayrollDatabase {

    private static Map<Integer, Employee> itsEmployees = new HashMap<>();

    private static Map<Integer, Employee> memberEmployees = new HashMap<>();

    public static Employee getEmployee(int empId) {
        return itsEmployees.get(empId);
    }

    public static List<Integer> getAllEmployeeIds() {
        return new ArrayList<>(itsEmployees.keySet());
    }

    public static void addEmployee(int empId, Employee employee) {
        itsEmployees.put(empId, employee);
    }

    public static void deleteEmployee(int empId) {
        itsEmployees.remove(empId);
    }

    public static Employee getUnionMember(int memberId) {
        return memberEmployees.get(memberId);
    }

    public static void addUnionEmployee(int memberId, Employee employee) {
        memberEmployees.put(memberId, employee);
    }

    public static void removeUnionMember(int memberId) {
        memberEmployees.remove(memberId);
    }

    public static void clear() {
        itsEmployees.clear();
    }
}
